<?php

/**
 * This file is part of the Pagizer package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @copyright   Copyright (c) 2010 Advisa (http://www.advisa.fr)
 * @author      Pagizer Core Team <team@pagizer.org>
 * @package     pagizer
 * @subpackage  website
 */

class m_website_views_DisplaySuccessView extends m_backoffice_extends_View
{
	public function execute()
	{
        /* @var $page m_website_documents_Page */
		$tpl = $this->getTemplateEngine()->disableCache();
		
		$tpl->setModuleTemplate("website", "front/block/BaseBlocks.html")->setFrontTheme(f_core_Context::getInstance()->getContext("currentWebsite")->getTheme());

		$page = $this->getModel("page");

		$tpl->assign("content", $page->getFormattedPageContent());

		ob_start();
		$tpl->renderDisplay();
		$content = ob_get_contents();
		ob_end_clean();
		
		$page = f_core_Context::getInstance()->getContext("currentPage");

		if(!is_null($page->getRedirect()))
		{
		    m_website_services_PageService::getInstance()->redirectToTargetedPage("404", $page->getWebsiteId(), $page->getLang());
		}
		
		$tpl->setModuleTemplate("website", "front/layout/Base.html");
				
		$tpl->assign("mainContent", $content);
		$tpl->assign("page", $page);
		$tpl->assign("website", $this->getCurrentWebsite());
		$tpl->assign("user", f_context_User::getInstance()->getUser());

		$tpl->renderDisplay(false);
	}
}